package com.mall.b2c.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mall.b2c.enums.LogType;
import com.mall.b2c.service.OrderLogService;
import com.mall.b2c.util.JsonDataGridHelper;
import com.mall.common.bean.Pager;
import com.mall.common.bean.SearchFilter;
import com.mall.common.controller.BaseAuthController;
import com.mall.common.util.EnumUtils;
import com.mall.common.web.Servlets;


/**
 * 后台Action类 - 订单日志
 */
@Controller
@RequestMapping("/admin/b2c/orderLog")
public class OrderLogController  extends BaseAuthController {

    @Resource private OrderLogService orderLogService;
    /**
     * 跳转到列表
     *
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public String list(Model model) {
        model.addAttribute("logType", EnumUtils.enumProp2I18nList(LogType.class));
        return "/admin/b2c/orderlog/list";
    }

    /**
     * 列表
     */
    @RequestMapping(value = "/queryData", method = RequestMethod.POST)
    @ResponseBody
    public Pager queryData(Pager pager, HttpServletRequest request) {
        Map<String, Object> filterParams = Servlets
                .getParametersStartingWith(request);
        List<SearchFilter> filters = SearchFilter.parse(filterParams);
        pager = orderLogService.findPage(pager, filters);
        return JsonDataGridHelper.createJSONData(pager);
    }
}
